package com.yn.service.zy.model.dto;

import com.yn.common.model.zy.InspectionOrderDO;
import com.yn.common.utils.BeanUtils;
import com.yn.common.utils.MoneyUtils;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.Objects;

/**
 * @ClassName: InspectionOrderDTO
 * @Description: 检查项订单
 * @Author: ym
 * @Date: 2025/5/10 15:59
 **/
@Data
public class InspectionOrderDTO {
    /** 主键 */
    private Integer id;
    /** 订单编号 */
    @ApiModelProperty(value = "订单编号")
    private String inspectionOrderNo;
    /** 订单总价格 */
    @ApiModelProperty(value = "订单总价格")
    private BigDecimal inspectionOrderPrice;
    /** 优惠金额 */
    @ApiModelProperty(value = "优惠金额")
    private BigDecimal preferentialPrice;
    /** 优惠券id */
    @ApiModelProperty(value = "优惠券")
    private Integer couponId;
    /** 微信支付单号 */
    @ApiModelProperty(value = "微信支付单号")
    private String weChatPayNo;
    /** 实际支付金额 */
    @ApiModelProperty(value = "实际支付金额")
    private BigDecimal inspectionPayPrice;
    /** 退款金额 */
    @ApiModelProperty(value = "退款金额")
    private BigDecimal orderReturnMoney;
    /** 退款状态 0:待审核 1：退款中 2：退款完成 3：退款失败 */
    @ApiModelProperty(value = "退款状态 0:待审核 1：退款中 2：退款完成 3：退款失败")
    private Integer orderReturnStatus;
    /** 支付状态 1：已支付 0；未支付 3:退款 */
    @ApiModelProperty(value = "支付状态 1：已支付 0；未支付 3:退款")
    private Integer payStatus;
    /** 订单评价 */
    @ApiModelProperty(value = "订单评价")
    private String orderEvaluation;
    /** app用户id */
    @ApiModelProperty(value = "app用户id")
    private Integer appUserId;
    /** 修改人id */
    @ApiModelProperty(value = "修改人id")
    private Integer updateId;
    /** 创建时间 */
    @ApiModelProperty(value = "创建时间")
    private LocalDateTime createTime;


    public static InspectionOrderDTO transform(InspectionOrderDO inspectionOrderDO){
        if (Objects.isNull(inspectionOrderDO)) {
            return null;
        }
        InspectionOrderDTO inspectionOrderDTO = BeanUtils.copyProperties(inspectionOrderDO, InspectionOrderDTO.class);
        if (Objects.nonNull(inspectionOrderDO.getInspectionOrderPrice())){
            inspectionOrderDTO.setInspectionOrderPrice(MoneyUtils.fen2yuan(inspectionOrderDO.getInspectionOrderPrice()));
        }
        if (Objects.nonNull(inspectionOrderDO.getPreferentialPrice())){
            inspectionOrderDTO.setPreferentialPrice(MoneyUtils.fen2yuan(inspectionOrderDO.getPreferentialPrice()));
        }
        if (Objects.nonNull(inspectionOrderDO.getInspectionPayPrice())){
            inspectionOrderDTO.setInspectionPayPrice(MoneyUtils.fen2yuan(inspectionOrderDO.getInspectionPayPrice()));
        }
        if (Objects.nonNull(inspectionOrderDO.getOrderReturnMoney())){
            inspectionOrderDTO.setOrderReturnMoney(MoneyUtils.fen2yuan(inspectionOrderDO.getOrderReturnMoney()));
        }
        return inspectionOrderDTO;
    }
}
